﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using QLHD.BUS;

namespace QLHD
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            DataTable dt = BoBussiness.ValidateUser(txtName.Text, txtPass.Text);
            if (dt != null && dt.Rows.Count > 0)
            {
                Session["UserName"] = dt.Rows[0]["UserName"].ToString();
                Session["Role"] = dt.Rows[0]["Role"].ToString();
                FormsAuthentication.RedirectFromLoginPage(txtName.Text, chkRemember.Checked);
            }
            else
                ltrScript.Text = "<script type=\"text/javascript\">$.jGrowl('Tài khoản đăng nhập không chính xác', { sticky: false, theme: 'growl-error', header: 'Lỗi!' });</script>";

        }
    }
}